git stash apply syntax

February 28th, 2008

It took me a few tries to figure out how ‘git stash apply’ can apply a specific stash. The trick is you have to use the stash{@X} as listed in git stash list, not the string you gave it.

So if git stash list has

bcooke@cc $ git stash list
stash@{0}: On local-trunk: names changed to protect w/ correct files
stash@{1}: On local-trunk: the innocent
stash@{2}: On local-trunk: background that thing

To apply the stash named “background that thing” I just have to run

git stash apply stash@{2}

and all is well.

2 Responses to “git stash apply syntax”

  1. Darcy Says:

    Thx for this - was driving me bonkers trying to get it right.

  2. Jarrod Says:

    Its not very obvious is it? I had also assumed you would apply the stash via the name it was given.

Leave a Reply